package Lee_code;

import java.util.Hashtable;

public class Lee_383
{
    public boolean canConstruct(String ransomNote, String magazine)
    {

        Hashtable<Character, Integer> hashtable = new Hashtable<>();
        char[] in = magazine.toCharArray();
        for(char i: in)
        {
            hashtable.put(i, hashtable.getOrDefault(i, 0)+1);
        }

        Hashtable<Character, Integer> hashtable_2 = new Hashtable<>();
        char[] in_2 = ransomNote.toCharArray();
        for(char i: in_2)
        {
            hashtable_2.put(i, hashtable_2.getOrDefault(i, 0)+1);
        }
        for(char i: hashtable_2.keySet())
        {
            if(!hashtable.containsKey(i)||hashtable_2.get(i)>hashtable.get(i))
                return false;
        }
        return true;
    }
}
